﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Script.Serialization;
using Utilities;

namespace Models.WebSite_HaiSheng
{
    public class Case : EntityBase
    {
        [Display(Name = "案例名称"), Required()]
        public string Title { get; set; }

        [Display(Name = "副标题")]
        public string SubTitle { get; set; }

        [Display(Name = "发布人"), Required()]
        public string Pubulisher { get; set; }

        [Display(Name = "发布时间"), Required()]
        public DateTime PubulishTime { get; set; }

        [Display(Name = "内容")]
        public string Content { get; set; }

        [Display(Name = "案例类型"), Required(ErrorMessage = "请选择案例的类型")]
        public string CaseType { get; set; }

        public List<Image> GetImages()
        {
            var imgs = from ir in CH.DB.ImageRelateTos
                       from image in CH.DB.Images
                       where image.ID == ir.ImageId && ir.RelateId == this.ID && ir.RelateType == "Case"
                       select image;

            var list = imgs.ToList();

            return list;
        }
    }
}